using System;
using SimpleJSON;

namespace Gj
{
    public class RadarAgentHelper : NodeHelper
    {
        public BindDataType type = BindDataType.List;
        private RadarHelper _RadarHelper;

        private RadarHelper RadarHelper
        {
            get
            {
                if (_RadarHelper == null) _RadarHelper = GetComponent<RadarHelper>();
                return _RadarHelper;
            }
        }

        protected override BindDataType bindDataType => type;

        protected override void BindData(string s)
        {
            var t = s.Split(",");
            var list = new float[t.Length];
            for (var i = 0; i < t.Length; i++) list[i] = Convert.ToSingle(t[i]);
            RadarHelper.SetValue(list);
        }

        protected override void BindData(JSONArray arr)
        {
            var list = new float[arr.Count];
            for (var i = 0; i < arr.Count; i++) list[i] = arr[i].AsFloat;
            RadarHelper.SetValue(list);
        }
    }
}